﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Data;
using log4net;
using Services.Implement;
using Services.Interface;

namespace LYPrice.Controllers
{
    public class ResultController : Controller
    {
        //
        // GET: /Result/
        private ILog logger = LogManager.GetLogger("");
        public ActionResult NotInList()
        {
            return View();
        }

        public ActionResult CantGetInfoFromWeixin()
        {
            return View();
        }

        public ActionResult Successful()
        {
            return View();
        }


        public ActionResult HaveLog()
        {
            return View();
        }

        public ActionResult ErrorInfo()
        {
            return View();
        }

        public ActionResult Exception()
        {
            return View();
        }

        public ActionResult RankingList()
        {
            try
            {
                IInitPageService initPageService = new InitPageService();
                var temp = ConfigurationManager.AppSettings["rankingnum"];
                int num;
                if (string.IsNullOrEmpty(temp))
                {
                    num = 20;
                }
                else
                {
                    int.TryParse(temp, out num);
                }

                List<User> rankingList = initPageService.GetTopUsers(num);
                if (rankingList == null)
                {
                    rankingList = new List<User>();
                }
                ViewData["Ranking"] = rankingList;
                return View("RankingList");
            }
            catch (Exception e)
            {
                logger.Error("Ranking List error" + e);
                return Redirect("~/Result/Exception");
            }

        }
    }
}
